<template>
  <div class="top">
    <div class="left">
      <img src="http://www.yechtech.com/static/img/logo.6b2e7950.png" alt="">
    </div>
    <div class="right">
      <div class="item" v-for="(item, i) in navData" :key="i" :class=" [ activeId===i ? 'active':'']" @click="toPage(i, item.path)">{{item.name}}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TopBar',
  data () {
    return {
      activeId: 0,
      navData: [
        {
          name: '首页',
          path: '/home'
        },
        {
          name: '数据中心',
          path: '/data'
        },
        {
          name: '产品',
          path: '/product'
        },
        {
          name: '解决方案',
          path: '/solutions'
        },
        {
          name: '业务咨询与服务',
          path: '/service'
        },
        {
          name: '关于我们',
          path: '/about'
        }
      ]
    }
  },
  methods: {
    //  编程式导航
    toPage (i, path) {
      this.activeId = i
      this.$router.push(path)
    }
  }
}
</script>

<style lang="less" scoped>
  *{
    margin: 0;
    padding: 0;
  }
  .top{
    height: 80px;
    width: 100%;
    /*background-color: #f00;*/
    >.left{
      float: left;
      margin-left: 50px;
      >img{
        height: 36px;
        width: 147px;
        margin-top: 20px;
      }
    }
    >.right{
      float: right;
      display: flex;
      flex-direction: row;
      justify-content: right;
      margin-right: 50px;
      text-align: center;
      >.item{
        line-height: 80px;
      }
      >.item:nth-child(1){
        width: 50px;
      }
      >.item:nth-child(2){
          width: 150px;
        }
      >.item:nth-child(3){
            width:50px;
      }
      >.item:nth-child(4){
              width: 150px;
      }
      >.item:nth-child(5){
         width: 200px;
       }
      >.item:nth-child(5){
        width: 200px;
      }
      >.active{
        border-bottom: 2px solid #4da7e3;
      }
    }
  }

</style>
